package com.leo.springbootmultithreadbasic.lock.reentranreadwritelock.writewrite;

/**
 * @author Leo
 * @version V1.0
 * @date 2021/11/5 10:31 PM
 */
public class MainDemo {
    public static void main(String[] args) {
        testWriteWrite();
    }


    /**
     * Test Result:
     * 同一时刻，只允许一个线程执行lock()方法后面的代码，体现了写锁写锁之间的互斥
     *
     */
    public static void testWriteWrite() {
        MyService myService = new MyService();

        // build thread
        for (int i = 0; i < 5; i++) {
            Thread thread = new Thread(new MyRunnable(myService));
            thread.setName(String.valueOf(i));
            thread.start();
        }
    }
}
